Navigation

  • index
  • next |
  • previous |
  • PyHowTo documentation »
  • Basic »
  • Datetime »

Table of Contents

Python v3.7 HowTos:

  • ----------------
  • Recursion
  • Backtracking
  • Dynamic Programming
  • Greedy
  • Sort
  • Binary Search
  • Depth First Search [DFS]
  • Breadth First Search [BFS]
  • Binary Search Tree [BST]
  • ----------------
  • Array
  • String
  • Heap
  • Stack
  • Queue
  • Tree
  • Linked List
  • Hash Table
  • Bit Manipulation
  • Two Pointers
  • Math
  • Decorator
  • ----------------
  • Basic
  • Intermediate
  • Advanced
  • Interview
  • ----------------
  • Spark
  • Tkinter
  • Turtle
  • Games
  • Web
  • ----------------
  • About
  • History

Previous topic

Convert the date to datetime (midnight of the date)

Next topic

Add 5 seconds with the current time

Quick search

Print next 5 days starting from todayΒΆ

Print next 5 days starting from today.
import datetime

base = datetime.datetime.today()

for x in range(0, 5):
      print(base + datetime.timedelta(days = x))

Output:

2017-05-06 12:27:53.632939
2017-05-07 12:27:53.632939
2017-05-08 12:27:53.632939
2017-05-09 12:27:53.632939
2017-05-10 12:27:53.632939

See also

https://www.w3resource.com/python-exercises/date-time-exercise/python-date-time-exercise-9.php

Navigation

  • index
  • next |
  • previous |
  • PyHowTo documentation »
  • Basic »
  • Datetime »
© Copyright 2020, Sergiy Zaytsev, szaytsev@hotmail.com. Created using Sphinx 2.3.0.